#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;

#define mes(x) memset(x,0,sizeof(x))

int low[MAXN],dfn[MAXN],n,ans,tot,root;
bool to[MAXN][MAXN];

void tarjin(int x){
	low[x] = dfn[x] = ++tot;
	int fla = 0,can = 0;
	for(int i = 1;i <= n;i++){
		if(!to[x][i]) continue;
		if(!dfn[i]){
			tarjin(i);
			low[x] = min(low[x],low[i]);
			if(low[i] >= dfn[x]){
				fla++;
				if(fla > 1 || x != root) can = 1;
			}
		}else low[x] = min(low[x],dfn[i]);
	}
	ans += can;
}

int main (){
	while(scanf("%d",&n) && n){
		mes(to); mes(low); mes(dfn); tot = 0;
		while(1){
			int u,x;char ch;
			scanf("%d",&u);if(!u) break;
			while(scanf("%d%c",&x,&ch)){
				to[x][u] = to[u][x] = 1;
				if(ch == '\n') break;
			}
		}
		ans = 0;
		for(int i = 1;i <= n;i++) if(!dfn[i]) root = i,tarjin(i);
		printf("%d\n",ans);
	}
	return 0;
}
